package DramScript
{
	import utils.Trace;
	
	// Safe return result from IScriptable.executeCommand
	public class ExecuteCommandResult
	{
		private var _resString:String;
		private var _branch:int;
		
		public function ExecuteCommandResult( res:String = "SUCCESS", branch:int = -1){
			switch( res ){
				case "SUCCESS":
				case "FAIL":
				case "WAIT":
					this._resString = res;
				break;
				case "BRANCH":
					if( branch < 0){
						Trace.throwError("ExecuteCommandResult() branch must be positive.");
					}
					this._resString = res;
					this._branch = branch;
				break;
				default:
					Trace.throwError("ExecuteCommandResult() resString must be SUCCESS, FAIL, WAIT, BRANCH: "+ res);
				break;
			}
		}
		public function get resString():String{
			return this._resString;
		}
		public function get branch():int {
			if( this._resString != "BRANCH"){
				Trace.throwError("ExecuteCommandResult() resString must be SUCCESS, FAIL, WAIT, BRANCH: "+this._resString );
			}
			return this._branch;
		}
	}
}